home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 August (Alt)
/
CHIP 2005-08.1.iso
/
program
/
guvenlik
/
syslinux-3.07.exe
/
com32
/
lib
/
strndup.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
C/C++ Source or Header
|
2004-11-10
|
224 b
|
18 lines
/*
* strndup.c
*/
#include <string.h>
#include <stdlib.h>
char *strndup(const char *s, size_t n)
{
int l = n > strlen(s) ? strlen(s)+1 : n+1;
char *d = malloc(l);
if (d)
memcpy(d, s, l);
d[n] = '\0';
return d;
}